﻿using Microsoft.Web.WebView2.Core;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WebAppraise
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            //InitializeComponent();
            this.Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            string currentPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //本地html文件，可以把css和js文件导入
            string filepath = currentPath + @"\Assets\htmlviews\index.html";
            if (File.Exists(filepath))
            {  //创建实例
              //  this.webView2_main.Source = new Uri(filepath);
                //导航完成监听
                // webView2_main.NavigationCompleted += WebView_Navigated;

            }


          //  this.webView2_main.CoreWebView2InitializationCompleted += WebView2_main_CoreWebView2InitializationCompleted;
        }

        private void WebView2_main_CoreWebView2InitializationCompleted(object? sender, CoreWebView2InitializationCompletedEventArgs e)
        {
            //本地路径
            string currentPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //本地html文件，可以把css和js文件导入
            string filepath = currentPath + @"\Assets\htmlviews\index.html";
            if (File.Exists(filepath))
            {  //创建实例
               // this.webView2_main.Source = new Uri(filepath);
                //导航完成监听
                // webView2_main.NavigationCompleted += WebView_Navigated;

            }
        }

        //private void WebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
        //{

        //}
    }
}